Fix gdbserver-xen support on older kernels.
authorKeir Fraser <keir.fraser@citrix.com>
Thu, 25 Mar 2010 07:41:55 +0000 (07:41 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Thu, 25 Mar 2010 07:41:55 +0000 (07:41 +0000)
The xc_ptrace API relies on errno for passing success/failure
indication back to callers.  However, mapping operations that fall
back on legacy APIs may leave errno set to a non-zero result even
thought the operation is successful.  This patch resets errno after
successful map operations so that xc_ptrace doesn't inadvertently
return a failure.

Signed-off-by: Justin Gibbs <gibbs@scsiguy.com>
tools/libxc/xc_ptrace.c

index 725a02233956de49a2856c497534f1d6f09da86c..e91ac56da6f95f85a2f18ddd7782479982d6f641 100644 (file)
@@ -193,6 +193,13 @@ map_domain_va(
     if (map == NULL)
         return NULL;
 
+    /*
+     * Due to the use of API fallback code in libxc, errno may
+     * be clobberred during successful operations.  Since the caller
+     * of xc_ptrace is depending on errno for return status, clear
+     * errno here.
+     */
+    errno = 0;
     return map + (va & ~PAGE_MASK);
 }